<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>倒计时</title>


    <script>
        function Time(time) {
            //输入时间
            var newTime = new Date(time);
            //现在时间
            var sj = (newTime.getTime() - Date.now()) / 1000;

            //天
            var a = sj / 60 / 60 / 24;
            a = a < 10 ? '0' + a : a;
            var b = sj / 60 / 60 % 24;
            //小时
            b = b < 10 ? '0' + b : b;
            //分
            var c = sj / 60 % 60;
            c = c < 10 ? '0' + c : c;
            //秒
            var d = sj % 60;
            d = d < 10 ? '0' + d : d;
            return parseInt(a) + '天' + parseInt(b) + '时' + parseInt(c) + '分' + parseInt(d) + '秒';
        }

        console.log(Time('2020-8-15 20:35:00'));
    </script>




</head>

<body>

</body>

</html>